﻿using System;

    class AllPrimesTo10000000

                // Write a program that finds all prime numbers in the range [1...10 000 000]. Use the sieve of Eratosthenes algorithm (find it in Wikipedia).

{
    static void Main()
    {
        bool[] array = new bool[10000000];

        for (int i = 2; i * i <= array.Length; i++)
        {
            if (!array[i])
            {
                for (int j = i * i; j < array.Length; j += i)
                array[j] = true;
            }
        }
        for (int i = 2; i < array.Length; i++)
        {
            if (!array[i])
            Console.Write(i + ",");
        }
    }
}

